function myready() {
				$(".editpan").click(function() {

				var pan = $(".add_tb .pan").val();
       
				$.ajax({
					type: 'POST',
					url: 'account.php',
					data: "xtype=changepan&pan=" + pan,
					success: function(m) {
						if (Number(m) == 1) {
							alert("ok");
						}
					}
				});
				return false;
			});
			
							$(".editgid").click(function() {

				var gid = $("select.gametype").val();
       
				$.ajax({
					type: 'POST',
					url: 'account.php',
					data: "xtype=changegid&gid=" + gid,
					success: function(m) {
						if (Number(m) == 1) {
							alert("ok");
						}
					}
				});
				return false;
			});

	$(".editpself").click(function(){
		$.ajax({
			type: 'POST',
			url: 'account.php',
			data: "xtype=pself",
			success: function(m) {
				if (Number(m) == 1) {
					alert('ok');
				}
			}
		});
	
	});
	
	$(".add").click(function(){
		 $(".addtb").show('fast');		 
         $("#action").val('add');
		 $("#user1").attr('disabled',false);
		 $("#user1").val('');
		 var posi=$(this).position();
		 $(".addtb").css('left',posi.left+$(this).width()-150);
		 $(".addtb").css('top',posi.top+$(this).height());
		 $("#addbtn").val("添加");
	});
	$(".edit").click(function(){
	     var uid=$(this).attr('uid');
		 $(".addtb").show('fast');
		 $("#action").val('edit');
		 $("#user1").val($(this).attr('username').replace($("#user0").html(),''));
		 $("#user1").attr('disabled',true);		
		 var posi=$(this).position();
		 $(".addtb").css('left',posi.left+$(this).width()-150);
		 $(".addtb").css('top',posi.top+$(this).height());
		 $("#addbtn").val("修改");

	});

   $("label").addClass("red");
	$(".page td img").click(function(){
	     var uid=$(this).attr('uid');
		 var page=$(this).attr('page');		
		 if(Number($(this).attr('ifson'))!=1) return false;
		 updatepage(uid,page);
	
	});
	$("#addbtn").click(function(){sendvalue();});
	$("#closebtn").click(function(){$(".addtb").hide();});
	$(".del").click(function(){
		var username = $(this).parent().parent().find("td:eq(0)").html();
	     if(!confirm("确定要删除子帐号吗"+username)){
			  return false;
	    }
		 var uid=$(this).attr('uid');
		 $.ajax({type:'POST',url:'suser.php',data:"xtype=editsondel&uid="+uid,success:function(m){																						  				if(Number(m)==1) {
				   alert("删除成功");
				   $("#del"+uid).parent().parent().remove();
				   window.location.href=window.location.href;
				}else{
				    alert("删除失败");
				}																		   
		 }});
	});
			$(".record").click(function(){
			   if($(this).val()=='记录'){							
			     var uid = $(this).attr('uid');
				 var username = $(this).attr('username');
				 var posi= $(this).position();
				 $(".recordtb").css("left",posi.left+$(this).width()-$(".recordtb").width());
				 $(".recordtb").css("top",posi.top+$(this).height());
				 showrecord(uid,username);
				 $(".recordtb").show();
				 $(this).val("关闭记录");
			   }else{
			       $(this).val("记录");
				   $(".recordtb").hide();
			   }
			});
}

function showrecord(uid,username){

		$.ajax({
		type: 'POST',
		url: 'suser.php',
		
		dataType:'json',
		data: 'xtype=showrecord&uid=' + uid+"&username="+username,
		cache:false,
		success: function(m) {	
            //$("#test").html(m);
			var el = 0;
			if (m['e'] != undefined) el = m['e'].length;
			var ll = 0;
			if (m['l'] != undefined) ll = m['l'].length;
			var estr = "<tr><th>修改时间</th><th>修改者</th><th>修改IP</th><th>来源</th><th>备注</th></tr>";
			var lstr = "<tr><th>登陆时间</th><th>IP</th><th>来源</th><th>备注</th></tr>";
			for (i = 0; i < el; i++) {
				estr += "<tr>";
				estr += "<td>" + m['e'][i]['moditime'] + "</td>";
				estr += "<td>" + m['e'][i]['modiuser'] + "(" + m['e'][i]['modisonuser'] + ")</td>";
				estr += "<td>" + m['e'][i]['modiip'] + "</td>";
				estr += "<td>" + m['e'][i]['addr'] + "</td>";
				estr += "<td>" + m['e'][i]['action'] + "</td>";
				estr += "</tr>"
			}
			for (i = 0; i < ll; i++) {
				lstr += "<tr>";
				lstr += "<td>" + m['l'][i]['time'] + "</td>";
				lstr += "<td>" + m['l'][i]['ip'] + "</td>";
				lstr += "<td>" + m['l'][i]['addr'] + "</td>";
				lstr += "<td>" + m['l'][i]['ifok'] + "</td>";
				lstr += "</tr>"
			}
			$(".recordtb .e").html("<table class='tinfo wd100'>" + estr + "</table>");
			$(".recordtb .l").html("<table class='tinfo wd100'>" + lstr + "</table>")
		}
	})
}
var strtest = /^[0-9a-zA-Z_]{1,}$/;
function sendvalue(){
    var uid=$("#uid").val();
    var action=$("#action").val();
	var username=$("#user0").html()+$("#user1").val();
	var pass1=$("#pass1x").val();
	var pass2=$("#pass2x").val();
	if(action=='add' & !strtest.test(username)){
	     alert("用户名只能输入大小写字母与数字");
	     return false;
	}
	if(pass1==''  | pass1!=pass2){
	     alert("密码不能为空，并且两次密码必需输入一样");
	     return false;
	}
	var sendstr='&username='+username+'&pass1='+men_md5_password(pass1)+"&pass2="+men_md5_password(pass2)+"&action="+action+"&uid="+uid;
	
	$.ajax({type:'POST',url:'account.php',data:'xtype=addoredit'+sendstr,success:function(m){

		 if(Number(m)!=1){		     	
			 if(action=='add'){
		          alert("添加失败，请重试");	
		     }else{
		          alert("修改失败，请重试");
			 }
		 }else{
			 if(action=='add'){
		          alert("添加成功");
				  window.location.href=window.location.href;
				  
		     }else{
		          alert("修改成功");
			 }
			 $(".addtb").hide('fast'); 
			 
		 }

	}});
	 
	
}

function updatepage(uid,page){
	$.ajax({type:'POST',url:'suser.php',data:'xtype=editsonupdatepage&uid='+uid+'&page='+page,success:function(m){
		 
		 if(Number(m)==1 | Number(m)==0){
	         $(".page img").each(function(){
			     if($(this).attr('uid')==uid & $(this).attr('page')==page){
				     $(this).attr('src',globalpath+'img/'+m+'.gif');
				 }
			 })
		 }
	}});
}



function strlen(sString){
    var sStr,iCount,i,strTemp ; 
    iCount = 0 ;
    sStr = sString.split("");
    for (i = 0 ; i < sStr.length ; i ++){
        strTemp = escape(sStr[i]); 
        if (strTemp.indexOf("%u",0) == -1) 
		{ 
            iCount = iCount + 1 ;
        } 
        else 
        {
            iCount = iCount + 2 ;
        } 
    }
    return iCount ;
}